/**
 *
 */
package com.ybkj.daijia.server.service.impl;


import com.ybkj.daijia.server.mapper.PhoneRecordMapper;
import com.ybkj.daijia.server.model.PhoneRecord;
import com.ybkj.daijia.server.service.PhoneRecordService;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Shine
 *
 */
@Service
public class DefaultPhoneRecordService implements PhoneRecordService {

    @Autowired
    private PhoneRecordMapper phoneRecordMapper;


    public PhoneRecord findOne(Long id) {

        return phoneRecordMapper.selectByPrimaryKey(id);
    }


    @Transactional(rollbackFor = Exception.class)
    public void delete(PhoneRecord phoneRecord) {

        phoneRecordMapper.deleteByPrimaryKey(phoneRecord.getId());

    }

    @Transactional(rollbackFor = Exception.class)
    public void delete(Long[] ids) {

        phoneRecordMapper.batchDeleteByPrimaryKey(ids);

    }

    @Override
    public List<PhoneRecord> findByDriverAndPhoneDate(Long driverId, String phoneDate) {

        return phoneRecordMapper.selectByDriverAndPhoneDate(driverId, phoneDate);
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public PhoneRecord insertRecord(PhoneRecord phoneRecord) {

        phoneRecordMapper.insertRecord(phoneRecord);

        return phoneRecord;
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public int updateByPrimaryKey(PhoneRecord record) {

        return phoneRecordMapper.updateByPrimaryKey(record);
    }

}